package com.allianz.webapps.controllers;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.allianz.webapps.https.interfaces.util.ObjectUtil;

import com.fasterxml.jackson.databind.ObjectMapper;


@Controller
@RequestMapping(value="/crsAction")
public class AppCRSController {
	
	@Autowired
	private ObjectMapper objectMapper;
	@Autowired
	private ObjectUtil objectUtil;
	
	@RequestMapping(value="/toCRS")
	public String toURL(){
		return "views/page/CRS";
	}
	
	@RequestMapping(value="/saveCRS")
	@ResponseBody
	public String appSaveCRS(@RequestParam(value="jsonParam") String jsonParam) throws Exception{
		Object obj=objectMapper.readValue(jsonParam,Object.class);
		String body=objectUtil.requestParam(obj, "app.saveCRS");
		return body;
	}
	
	@RequestMapping(value="/editCRS")
	@ResponseBody
	public String appEditCRS(@RequestParam(value="jsonParam") String jsonParam)throws Exception{
		Object obj=objectMapper.readValue(jsonParam,Object.class);
		String body=objectUtil.requestParam(obj, "app.editCRS");
		return body;
	}
}
